package com.liusha.quicksand.dao;

import com.liusha.quicksand.po.Comment;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 一世长安一世欢
 * @Date: 2020/10/23
 * @Time: 17:20
 * @Description: No Description
 */
public interface CommentRepository extends JpaRepository<Comment, Long>, JpaSpecificationExecutor<Comment> {

    List<Comment> findByBlog_BlogIdAndParentCommentNull(Long blogId, Sort sort);

    @Query("select c from Comment c where c.blog like ?1 or c.commentId like ?1 or c.nickname like ?1 or c.content like ?1 ")
    Page<Comment> findByKeyWords(String kws, Pageable pageable);

}
